#include				<iostream>
#include				"Menu.hh"

Menu::Menu(sf::RenderWindow &win)
	:	_window(win), _pvpZone(new sf::Rect<int>(322, 254, 507, 273)), _pvIAZone(new sf::Rect<int>(322, 289, 507, 308)), _color(sf::Color(0, 0, 0, 0)),
		_pvpRect(sf::Shape::Rectangle(322, 254, 507, 273, _color, 1, sf::Color::Black)), _pvIARect(sf::Shape::Rectangle(322, 289, 507, 308, _color, 1, sf::Color::Black)),
		_onPvpZone(false), _onPvIAZone(false), _gameType(0)
{
	_screenImage.LoadFromFile(MENU_PATH);
	_screen.SetImage(_screenImage);
	_screen.SetPosition(0, 0);
}

Menu::~Menu()
{

}

void					Menu::draw()
{
	_window.Draw(_screen);
	_window.Draw(_pvpButton);
	_window.Draw(_pvIAButton);
	if (_onPvpZone)
		_window.Draw(_pvpRect);
	if (_onPvIAZone)
		_window.Draw(_pvIARect);
}

void					Menu::mouseMoveEvent(sf::Event::MouseMoveEvent &event)
{
	if (_pvpZone->Contains(event.X, event.Y))
	{
		_onPvpZone = true;
		_onPvIAZone = false;
	}
	else if (_pvIAZone->Contains(event.X, event.Y))
	{
		_onPvIAZone = true;
		_onPvpZone = false;
	}
	else
	{
		_onPvIAZone = false;
		_onPvpZone = false;
	}
}

bool					Menu::mouseButtonEvent(sf::Event::MouseButtonEvent &event)
{
	if (_onPvpZone)
	{
		_gameType = 0;
		return (true);
	}
	else if (_onPvIAZone)
	{
		_gameType = 1;
		return (true);
	}
	return (false);
}

void					Menu::initPlayers(int type)
{
}

int				const	Menu::getGameType() const
{
	return (_gameType);
}